<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	  <%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
	  
 <c:choose>
<c:when test="${msg=='新增成功' }">
 <script>alert('新增成功，请等待公司审核')</script>
</c:when>
</c:choose>

<%request.removeAttribute("msg"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="gbk">
<title>添加商品</title>
<link type="text/css" rel="stylesheet"
	href="fontsawesome/css/font-awesome.css" />
<link type="text/css" rel="stylesheet" href="css/style_index.css" />
<link type="text/css" rel="stylesheet" href="css/datepicker.css" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
	@keyframes fade-in {  
    0% {opacity: 0;}/*初始状态 透明度为0*/  
    40% {opacity: 0;}/*过渡状态 透明度为0*/  
    100% {opacity: 1;}/*结束状态 透明度为1*/  
	}  
	
	@-webkit-keyframes fade-in {/*针对webkit内核*/  
    0% {opacity: 0;}  
    40% {opacity: 0;}  
    100% {opacity: 1;}  
	}  
	
	body {    
    animation: fade-in;/*动画名称*/  
    animation-duration: 1.5s;/*动画持续时间*/  
    -webkit-animation:fade-in 1.5s;/*针对webkit内核*/  
	}  
</style>
</head>
<body>
	<div class="main_box">
		<h2>
			<span></span>添加商品
		</h2>
		<div class="cont_box">
			<c:choose>
				<c:when test="${merchaned.name!=null }">
					<form action="merchaned?flag=update1" method="post" id="user_form">
				</c:when>
				<c:when test="${merchaned.name==null }">
					<form action="addmerchaned" method="post" id="user_form"  enctype="multipart/form-data">
				</c:when>
			</c:choose>
				<input type="hidden" value="${merchaned.id}" name="id">
				<ul class="addpro_box adduser_box">
					<li><label>商品名称：</label> <input type="text" placeholder="请输入商品名称"
						name="name"  data-rule-fullname="true"
						required="required" value="${merchaned.name }"/></li>
                    <li><label>商品金额：</label> <input type="text" placeholder="请输入商品金额"
                                                  name="money"  data-rule-fullname="true" oninput="value=value.replace(/[^\d]/g,'')"
                                                  required="required" value="${merchaned.money}"/></li>
					<li><label>类别</label>
						<div class="vocation">
						<c:choose>
						<c:when test="${merchaned.lb==1 }">
							<select class="select1" name="lb" required="required">
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='3'>酒水</option>
								<option value='4'>日用</option>
								<option value='5'>游戏</option>
								<option value='6'>生计</option>
							</select>
						</c:when>
						<c:when test="${merchaned.lb==2 }">
							<select class="select1" name="lb" required="required">
								<option value='2'>烟草</option>
								<option value='1'>食品</option>
								<option value='3'>酒水</option>
								<option value='4'>日用</option>
								<option value='5'>游戏</option>
								<option value='6'>生计</option>
							</select>
						</c:when>
						<c:when test="${merchaned.lb==3 }">
							<select class="select1" name="lb" required="required">
								<option value='3'>酒水</option>
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='4'>日用</option>
								<option value='5'>游戏</option>
								<option value='6'>生计</option>
							</select>
						</c:when>
						<c:when test="${merchaned.lb==4 }">
							<select class="select1" name="lb" required="required">
								<option value='4'>日用</option>
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='3'>酒水</option>
								<option value='5'>游戏</option>
								<option value='6'>生计</option>
							</select>
						</c:when>
						<c:when test="${merchaned.lb==5 }">
							<select class="select1" name="lb" required="required">
								<option value='5'>游戏</option>
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='3'>酒水</option>
								<option value='4'>日用</option>
								<option value='6'>生计</option>
							</select>
						</c:when>
						<c:when test="${merchaned.lb==6 }">
							<select class="select1" name="lb" required="required">
								<option value='6'>生计</option>
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='3'>酒水</option>
								<option value='4'>日用</option>
								<option value='5'>游戏</option>
							</select>
						</c:when>
							<c:when test="${merchaned.lb==null}">
								<select class="select1" name="lb" required="required">
								<option value='1'>食品</option>
								<option value='2'>烟草</option>
								<option value='3'>酒水</option>
								<option value='4'>日用</option>
								<option value='5'>游戏</option>
								<option value='6'>生计</option>
								</select>
							</c:when>
						</c:choose>
						</div></li>
					<c:choose>
					<c:when test="${merchaned.photo==null }">
						<li><label>商品图片：</label>
							<div class="a1">
								<input type="file" name="photo" style="display: none" id="photo_fwp" >
									<div id="path"></div>
								<input type="button" class="loginbtn" name="photo" id="selectBtn" value="上传商品图片" required="required">
							</div>
						</li>
					</c:when>
					<c:when test="${merchaned.photo!=null }">
						<li><label>商品图片：</label>
						<div class="a1">
							<img alt="${merchaned.name }" src="http:\\<%=request.getServerName() %>:8080\merchaned_photo/${merchaned.photo }">
						</div>
					</li>
					</c:when>
					</c:choose>
				</ul>
				<c:choose>
					<c:when test="${merchaned.name!=null }">
						<div class="probtn_box clearfix">
							<input type="submit" value="修改商品" class="btn blue_btn" style="margin-left: 180px;	"/>
						</div>
					</c:when>
					<c:when test="${merchaned.name==null }">
						<div class="probtn_box clearfix">
							<input type="submit" value="添加商品" class="btn blue_btn" style="margin-left: 180px;	"/>
						</div>
					</c:when>
				</c:choose>
				
			</form>
		</div>
	</div>
	<script type="text/javascript">
		
		//给选择文件按钮绑定单击事件
		$("selectBtn").addEventListener("click", function() {
			//调用文件控件的单击事件
			$("photo_fwp").click();
		});
		//内容改变事件
		$("photo_fwp").addEventListener("change", function() {
			var dir = this.value;
			dir = dir.substring(dir.lastIndexOf("\\") + 1);
			$("path").innerHTML = "已选择文件" + dir;
		});
		

		function $(id) {
			return document.getElementById(id);
		}
	</script>
</body>
</html>